package Connection;

import java.io.DataOutputStream;

import lejos.nxt.comm.Bluetooth;
import lejos.nxt.comm.NXTConnection;

/**
 * Class for handling bluetooth connection and data streams.
 * 
 * @author Didzis Petkus, Danny Johansen, Liviu Berheci
 * 
 */
public class Connector {

	private NXTConnection connection;
	private DataOutputStream outStream;

	/**
	 * Default constructor. Waits for the bluetooth connection and opens output
	 * stream.
	 */
	public Connector() {
		this.connection = Bluetooth.waitForConnection();
		this.outStream = connection.openDataOutputStream();
	}

	/**
	 * Synchronized method for getting data output stream.
	 * 
	 * @return the outStream
	 */
	public DataOutputStream getOutStream() {
		synchronized (outStream) {
			return outStream;
		}
	}

}
